function removeElement(nums: number[], val: number): number {
    let i = 0;
    for (let item = 0; item < nums.length; item++) {
        console.log(nums[item]);
        if (nums[item] === val) {
            continue;
        
        } else {
            nums[i++] = nums[item];
        }
        // nums.length = i+1;
    }
    return nums.length;
};

// let nums = [3, 2, 2, 3], val = 3;
let nums =  [0,1,2,2,3,0,4,2], val = 2;
removeElement(nums, val);
console.log(nums);